﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Microsoft.Extensions.DependencyInjection;

partial class ServiceCollectionExtensions
{
    /// <summary>
    /// 启用内置编号机制。
    /// </summary>
    /// <param name="services"></param>
    /// <returns></returns>
    public static IServiceCollection EnableIdWorker(this IServiceCollection services, long workerId, long datacenterId, long sequence = 0L)
    {
        services.AddSingleton<Seagull.Foundation.IdWorker>((p) =>
        {
            Seagull.Internal.Snowflake.IdWorker idWorker = new(workerId, datacenterId, sequence);
            return idWorker;
        });
        return services;
    }
}
